﻿using System;

using Moe.ECamel.Client.ServiceProxies;
using Moe.ECamel.Client.WinForms.Common;
using Moe.ECamel.Common.Contracts;

namespace Moe.ECamel.Client.WinForms.Controls
{
	public partial class CustomersDebtsReportControl : ECamelUserControl
	{
		private int _libraryId;

		public CustomersDebtsReportControl()
		{
			InitializeComponent();
		}

		public void Initialize(int libraryId)
		{
			_libraryId = libraryId;
		}

		private void GenerateReportButton_Click(object sender, EventArgs e)
		{
			using (var serviceProxy = new ReportServiceProxy())
			{
				var request = new CustomersDebtsReportRequest();
				request.LibraryId = _libraryId;
				request.MinimumDebt = (int)MinimumDebtNumericBox.Value;
				request.MaxResults = (int)MaximumResultsNumericBox.Value;
				var result = serviceProxy.GenerateCustomersDebtsReport(request);
				webBrowser1.DocumentText = result;
			}
		}
	}
}
